package org.stone.project.tx.api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.stone.project.tx.config.CtxHolderProxy;
import org.stone.project.tx.pojo.dto.Result;
import org.stone.project.tx.pojo.vo.MessageClientVo;
import org.stone.project.tx.service.MsgService;

import javax.validation.Valid;

@RestController
@RequestMapping("cluster")
public class ClusterController {
    @Autowired
    private MsgService msgService;

    @GetMapping("getConnectIp")
    public Result getConnectIp(){
        /**
         * 连接是否存在
         */

        /**
         * 返回30s连接的ip
         */

        return null;
    }

    /**
     * 通过用户id获取连接数量
     * @return
     */
    @GetMapping("getConnectionByUserNum")
    public Result<Integer> getConnectionByUserNum(String userId){
        return Result.ok(CtxHolderProxy.getConnectionByUserNum(userId));
    }

    /**
     * 获取连接总数
     * @return
     */
    @GetMapping("getConnectionNum")
    public Result<Integer> getConnectionNum(){
        return Result.ok(CtxHolderProxy.getConnectionNum());
    }
}